package cn.edu.bupt.freewings.forum.front.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.bupt.freewings.forum.common.UserType;
import cn.edu.bupt.freewings.forum.client.rest.UserClient;
import cn.edu.bupt.freewings.forum.front.Constants;
import cn.edu.bupt.freewings.forum.front.beans.UserBean;
import cn.edu.bupt.freewings.forum.front.utility.CommonUtility;
import cn.edu.bupt.freewings.forum.common.PostType;
import cn.edu.bupt.freewings.forum.common.TopicType;
import cn.edu.bupt.freewings.forum.client.rest.PostClient;
import cn.edu.bupt.freewings.forum.front.utility.CommonUtility;

public class TopicController extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		Integer topicId = Integer.valueOf(request.getParameter("id"));
		PostType.PostList posts = new PostClient().getByTopicId(topicId, 0, 100);
		request.setAttribute("posts", CommonUtility.postListToPostBeanList(posts));
		request.getRequestDispatcher("/topic.jsp").forward(request, response);
	}
}
